import { _decorator, Component, Label, Node, v3 } from 'cc';
import ObjPool from '../DataCenter/ObjPool';
const { ccclass, property } = _decorator;

@ccclass('RoleView')
export class RoleView extends Component {
    @property(Node)
    mask: Node = null;
    @property(Node)
    itemPos: Node = null;
    @property(Label)
    desc: Label = null;

    roleName: string = null;
    roleNode: Node = null;

    onLoad() {
        this.mask.on(Node.EventType.TOUCH_END, () => {
            this.close();
        });
    }

    Show(roleId: string) {
        this.desc.string = `兵

描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述`

        let roleNode = ObjPool.inst.getRoleNode(roleId);
        roleNode.parent = this.itemPos;
        roleNode.position = v3(0, 0, 0);
        this.roleNode = roleNode;
        this.roleName = roleId;
    }

    close() {
        ObjPool.inst.putRoleNode(this.roleName, this.roleNode);
        this.roleName = '';
        this.roleNode = null;
        this.node.active = false;
    }
}


